<template>
  <div style="height: 100%;overflow:hidden" class="main">
    <!-- <x-header :left-options="{preventGoBack:true,backText: ''}" @on-click-back="backhome">隐患上报<div id="headeright"  @click="dangereport">上报</div></x-header> -->
    <x-header :left-options="{preventGoBack:true,backText: ''}" @on-click-back="backhome">
      日常巡检-离线
      <!-- <x-icon id="headeright" type="ios-plus-empty" size="30" @click="dangereport"></x-icon> -->
      <!-- <img slot="right" src="@/assets/img/offline_start.png" @click="dangereport" id="headeright" /> -->
      <img slot="right" src="@/assets/img/white_change.png" class="changeToOnline" @click="changeToOnline" />
    </x-header>
    <!-- <img
      src="@/assets/img/add_form.png"
      class="add_form"
      @click="dangereport"
      v-if="this.dailyArr.includes('0')"
    />-->
    <div class="add_form_new" @click="dangereport" v-if="this.dailyArr.includes('0')">发起</div>
    <div class="sup"></div>
    <cell is-link link="proListc">
      <span slot="title">{{showPro(pro)}}</span>
    </cell>
    <div class="sup"></div>
    <div class="main-container" style="overflow:auto;height:70%;">
      <v-touch v-on:swiperight="onSwipeRight" :swipe-options="{direction: 'horizontal'}">
        <div style="display: flex;align-items: center;height: 30px;margin-top: 10px;">
          <input type="checkbox" name="selectAll" class="selectHidanger" id="selectAll" @click="selectAll"
            v-model="checked" />
          <label for="selectAll"></label>
          <div>全选</div>
        </div>
        <div>
          <group v-for="(item, i) in list" gutter="-1px" :key="i">
            <div title :border-intent="false" style="display:flex">
              <input type="checkbox" name="selectHidanger" class="selectHidanger" :id="item.GUID" v-model="checkList"
                :value="item.GUID" />
              <label :for="item.GUID" style="width:30px"></label>
              <div class="more-box"
                style="margin-left: 30px;margin-right: 30px;margin-bottom: 15px;margin-top: 15px;width:100%"
                @click="openInfo(item)">
                <div class="project_style">
                  <span style="display:inline-block">{{item.PRJNAME}}</span>
                </div>
                <div class="state_time_style">
                  <div class="fill_user">
                    <span class="gray-label" style="margin-right: 10px;">填写人</span>
                    {{item.INPUTERFULLNAME}}
                  </div>
                  <div class="fill_time">
                    <span class="gray-label" style="margin-right: 10px;">填写时间</span>
                    {{item.INPUTDATE.substring(0,10)}}
                  </div>
                </div>
              </div>
            </div>
          </group>
        </div>
        <!-- </scroller> -->
      </v-touch>
    </div>
    <!-- <img :src="uploadImgUrl" class="upload" @click="uploadRecodes" v-show="uploadFlag" /> -->
    <div style="border-top: 1px solid #eeeeee;" v-show="uploadFlag">
      <div class="add_form" :disable="isDisable" @click="uploadRecodes">上传</div>
    </div>
    <router-view></router-view>
  </div>
</template>

<script>
  var $vue = {};
  import {
    Checklist,
    Loading
  } from "vux";
  import Vue from "vue";
  export default {
    name: "offlineCklist",
    // inject:['reload'],
    components: {
      Checklist,
      Loading
    },
    mounted() {
      //console.log("asdasdas");
      //console.log(row());
      //this.$router.go(0)
      //  this.reload();
      //location.reload()
      this.getDataOffline();
      this.pageToken = this.guid();
    },
    beforeCreate() {
      $vue = this;
    },
    data() {
      return {
        list: [],
        page: 1,
        keyword: "",
        createPop: false, //弹出层是否创建
        loading: false, //下拉刷新时禁止无限加载
        //currentTab:'待整改',
        //tabs:['待整改','已整改']
        pro: this.$route.query.pro,
        proId: this.$route.query.proId,
        site: this.$route.query.site,
        //   guid: '',
        filter: "",
        checkList: [],
        checked: false,
        checkSelect: "",
        uploadImgUrl: require("@/assets/img/upload.png"),
        selectedList: [], //已选中的list
        pageToken: "",
        fieldToken: "",
        imgList: this.$store.state.offlineflieurl, //本地图片存储路径
        offlineUrl: [], //要上传至服务器的url
        uploadFlag: false,
        dailyArr: this.$store.state.dailyArr,
        //proName:'',
        successFlag: 0,
        successFlagUpdate: [],
        isDisable: false
      };
    },
    methods: {
      upload(fileURL, data, length, index) {
        var success = r => {
          //上传成功
          console.log("传上成功");
          console.log("rrrrrrr", r);

          this.imgList.map(item => {
            if (true) {
              // if (this.belongSubSys != '') {
              item.fileOldName = JSON.parse(r.response)[0].name;
              item.fileId = JSON.parse(r.response)[0].id;
              item.fieldToken = JSON.parse(r.response)[0].fieldToken;
              item.size = JSON.parse(r.response)[0].size;
              // } else if (this.server != '') {
              // item.fileId = JSON.parse(r.response).fileId // moaapi/feedback 接口
              // }
            }
          });
          if (!this.successFlagUpdate[index]) {
            this.successFlagUpdate[index] = 0;
          }
          this.successFlagUpdate[index]++;
          if (this.successFlagUpdate[index] == length) {
            //发送系统消息
            var title = "日常巡检单提醒";
            var content =
              "你管理的" +
              data.PRJNAME +
              "项目有一个新的日常巡检单单。请进入【日常巡检】查看详细信息。";
            var messageto = data.SUPERVISORNAME;
            var url =
              process.env.BASE_URL +
              "qhszpm/forms/SM/SAFECHECKINSPECT/SAFECHECKINSPECT_Add.html?isBreak=false&objName=SAFECHECKINSPECT&_useType=view&_pk=GUID&_t=474914&_winid=w5240&_pkValue=" +
              data.GUID;

            var sendParams = {
              _method: "SYS_NOTICE.sendNotice",
              _param: {
                messageto: messageto,
                messagetilte: title,
                messagecontent: content,
                url: url,
                messagesenttime: new Date(),
                messageattachment: ""
              }
            };
            let sendJson = {
              FixJSON: JSON.stringify(sendParams)
            };
            this.$ajax({
                url: this.COMMON_URL,
                method: "post",
                // data: this.signMD5(sendJson)
                data: sendJson
              })
              .then(res => {})
              .catch(err => {
                console.log(err);
              });
            Vue.$vux.loading.show({
              text: "Loading"
            });
            this.successFlagUpdate[index] = 0;
            delete this.list[index];
            var params = {
              _method: "formService.saveFormData",
              requestEventData: {
                eventType: "formSubmitEvent",
                formType: 1,
                bizObjId: "SAFECHECKINSPECT",
                formId: "SAFECHECKINSPECT_Add",
                buttonId: "HandleCommand_1"
              },
              flowParam: {
                defKey: "SAFECHECKINSPECT",
                nodeId: "UserTask_1",
                userCommandType: "startandsubmit",
                userCommandId: "HandleCommand_1",
                isAdmin: "false",
                taskComment: "",
                extParam: {}
              },
              _OBJ_NAME_: "SAFECHECKINSPECT",
              _FORM_ID_: "SAFECHECKINSPECT_Add",
              useType: "add",
              pageToken: this.pageToken,
              formData: {
                objName: "SAFECHECKINSPECT",
                pks: ["GUID"],
                data: [{
                  rowData: [{
                      DataTarget: "GUID",
                      Value: data.GUID,
                      OriginalValue: null,
                      PK: true,
                      DataType: "String"
                    },
                    {
                      DataTarget: "STATE",
                      Value: "",
                      OriginalValue: null,
                      PK: false,
                      DataType: "String"
                    },
                    {
                      DataTarget: "ATTACHMENTS",
                      Value: "",
                      OriginalValue: null,
                      PK: false,
                      DataType: "Store.ecidiDoc"
                    },
                    {
                      DataTarget: "ATTACHMENTS2",
                      Value: "",
                      OriginalValue: null,
                      PK: false,
                      DataType: "Store.ecidiDoc"
                    },
                    {
                      DataTarget: "PRJNAME",
                      Value: data.PRJNAME,
                      OriginalValue: null,
                      PK: false,
                      DataType: "String"
                    },
                    {
                      DataTarget: "PRJNO",
                      Value: null,
                      OriginalValue: null,
                      PK: false,
                      DataType: "String"
                    },
                    {
                      DataTarget: "SYSPRJID",
                      Value: data.SYSPRJID,
                      OriginalValue: null,
                      PK: false,
                      DataType: "String"
                    },
                    {
                      DataTarget: "SUBJECT",
                      Value: data.SUBJECT,
                      OriginalValue: null,
                      PK: false,
                      DataType: "String"
                    },
                    {
                      DataTarget: "CHECKREQUIRED",
                      Value: data.CHECKREQUIRED,
                      OriginalValue: null,
                      PK: false,
                      DataType: "String"
                    },
                    {
                      DataTarget: "PLANDATE",
                      Value: data.PLANDATE + " 00:00:00.000",
                      OriginalValue: null,
                      PK: false,
                      DataType: "TimeStamp"
                    },
                    {
                      DataTarget: "FINISHDATE",
                      Value: "",
                      OriginalValue: null,
                      PK: false,
                      DataType: "TimeStamp"
                    },
                    {
                      DataTarget: "ATTACHMENTS",
                      Value: data.ATTACHMENTS,
                      OriginalValue: null,
                      PK: false,
                      DataType: "String"
                    },
                    {
                      DataTarget: "ATTACHMENTS2",
                      Value: "",
                      OriginalValue: null,
                      PK: false,
                      DataType: "String"
                    },
                    {
                      DataTarget: "DESCRIPTION",
                      Value: "",
                      OriginalValue: null,
                      PK: false,
                      DataType: "String"
                    },
                    {
                      DataTarget: "INPUTERFULLNAME",
                      Value: data.INPUTERFULLNAME,
                      OriginalValue: null,
                      PK: false,
                      DataType: "String"
                    },
                    {
                      DataTarget: "INPUTERNAME",
                      Value: data.INPUTERNAME,
                      OriginalValue: null,
                      PK: false,
                      DataType: "String"
                    },
                    {
                      DataTarget: "INPUTERDEPTNAME",
                      Value: data.INPUTERDEPTNAME,
                      OriginalValue: null,
                      PK: false,
                      DataType: "String"
                    },
                    {
                      DataTarget: "INPUTERDEPTID",
                      Value: data.INPUTERDEPTID,
                      OriginalValue: null,
                      PK: false,
                      DataType: "String"
                    },
                    {
                      DataTarget: "PHONENUM",
                      Value: data.PHONENUM,
                      OriginalValue: null,
                      PK: false,
                      DataType: "String"
                    },
                    {
                      DataTarget: "INPUTDATE",
                      Value: data.INPUTDATE,
                      OriginalValue: null,
                      PK: false,
                      DataType: "TimeStamp"
                    },
                    {
                      DataTarget: "NOTIFYCHECK",
                      Value: "",
                      OriginalValue: null,
                      PK: false,
                      DataType: "String"
                    },
                    {
                      DataTarget: "NOTIFYMETHOD",
                      Value: data.NOTIFYMETHOD,
                      OriginalValue: null,
                      PK: false,
                      DataType: "String"
                    },
                    {
                      DataTarget: "REFORMER",
                      Value: data.REFORMER,
                      OriginalValue: null,
                      PK: false,
                      DataType: "String"
                    },
                    {
                      DataTarget: "REFORMERID",
                      Value: data.REFORMERID,
                      OriginalValue: null,
                      PK: false,
                      DataType: "String"
                    },
                    {
                      DataTarget: "FLAG",
                      Value: "不合格",
                      OriginalValue: null,
                      PK: false,
                      DataType: "String"
                    },
                    {
                      DataTarget: "CHECKER",
                      Value: data.CHECKER,
                      OriginalValue: null,
                      PK: false,
                      DataType: "String"
                    },
                    {
                      DataTarget: "INSPECTMEMBERFULLNAME",
                      Value: data.INSPECTMEMBERFULLNAME,
                      OriginalValue: null,
                      PK: false,
                      DataType: "String"
                    },
                    {
                      DataTarget: "INSPECTMEMBERNAME",
                      Value: data.INSPECTMEMBERNAME,
                      OriginalValue: null,
                      PK: false,
                      DataType: "String"
                    },
                    {
                      DataTarget: "CHECKERID",
                      Value: data.CHECKERID,
                      OriginalValue: null,
                      PK: false,
                      DataType: "String"
                    },
                    {
                      DataTarget: "SUPERVISORFULLNAME",
                      Value: data.SUPERVISORFULLNAME,
                      OriginalValue: null,
                      PK: false,
                      DataType: "String"
                    },
                    {
                      DataTarget: "SUPERVISORNAME",
                      Value: data.SUPERVISORNAME,
                      OriginalValue: null,
                      PK: false,
                      DataType: "String"
                    }
                  ],
                  children: []
                }]
              },
              _ATTACHMENT_DELETE_IDS_: "",
              formInfo: {
                GUID: data.GUID,
                STATE: "",
                ATTACHMENTS: data.ATTACHMENTS,
                ATTACHMENTS2: "",
                PRJNAME: data.PRJNAME,
                PRJNO: "",
                SYSPRJID: data.SYSPRJID,
                SUBJECT: data.SUBJECT,
                CHECKREQUIRED: data.CHECKREQUIRED,
                PLANDATE: data.PLANDATE,
                FINISHDATE: "",
                DESCRIPTION: "",
                INPUTERFULLNAME: data.INPUTERFULLNAME,
                INPUTERNAME: data.INPUTERNAME,
                INPUTERDEPTNAME: data.INPUTERDEPTNAME,
                INPUTERDEPTID: data.INPUTERDEPTID,
                PHONENUM: data.PHONENUM,
                INPUTDATE: data.INPUTDATE,
                NOTIFYCHECK: "",
                NOTIFYMETHOD: data.NOTIFYMETHOD,
                REFORMER: data.REFORMER,
                REFORMERID: data.REFORMERID,
                FLAG: "不合格",
                CHECKER: data.CHECKER,
                INSPECTMEMBERFULLNAME: data.INSPECTMEMBERFULLNAME,
                INSPECTMEMBERNAME: data.INSPECTMEMBERNAME,
                CHECKERID: data.CHECKERID,
                SUPERVISORFULLNAME: data.SUPERVISORFULLNAME,
                SUPERVISORNAME: data.SUPERVISORNAME
              }
            };
            let json = {
              FixJSON: JSON.stringify(params)
            };
            this.$ajax({
                url: this.COMMON_URL +
                  "?_objName=SAFECHECKINSPECT&_useType=add&_defKey=Flow_SAFECHECKINSPECT&_pk=GUID&_pkValue=undefined",
                method: "post",
                data: json
              })
              .then(res => {
                console.log("日常巡检上传成功" + index);
                if (res.status == 200) {
                  this.uploadImgUrl = require("@/assets/img/upload.png");
                  this.$store.state.SQLiteDB.transaction(
                    tx => {
                      tx.executeSql('DELETE FROM PMHSE_CHECKLIST WHERE GUID="' + data.GUID + '"');
                    },
                    err => {
                      console.log("错误", err);
                    }
                  );
                }
                this.$store.state.SQLiteDB.transaction(tx => {
                  tx.executeSql(
                    "SELECT * FROM PMHSE_CHECKLIST",
                    [],
                    (tx, result) => {
                      if (result.rows.length == 0) {
                        this.list = [];
                      }
                      for (let i = 0; i < result.rows.length; i++) {
                        this.list[i] = result.rows.item(i);
                      }
                    }
                  );
                });
              })
              .catch(err => {
                //console.log(err);
                alert(err);
                //this.err='';
              });
          }
          // this.showPercent = false
          // this.percent = 0
          //  this.$emit('input', this.list)
          // this.show = false
        };
        var fail = error => {
          // 上传失败
          console.log(JSON.stringify(error));
          // //console.log('photoFailed')
          // this.showPercent = false
          // this.percent = 0
          // console.log("上传失败")
        };
        var options = new FileUploadOptions();
        console.log("fileUpload:" + options);
        options.fileKey = "fileName";
        options.fileName = fileURL.substr(
          fileURL.lastIndexOf("/"),
          fileURL.lastIndexOf("?") - fileURL.lastIndexOf("/")
        );
        if (!options.fileName) {
          options.fileName = fileURL.substr(fileURL.lastIndexOf("/"));
        }
        options.mimeType = "application/octet-stream";
        (options.httpMethod = "POST"),
        (options.headers = {
          Accept: "*/*",
          "Accept-Encoding:": "gzip, deflate",
          "Accept-Language": " zh-CN,zh;q=0.9",
          Connection: "keep-alive"
        });
        (options.chunkedMode = false),
        // 如果要传参数，写这里
        (options.params = {
          Filename: fileURL.substr(fileURL.lastIndexOf("/") + 1),
          Upload: "Submit Query"
          // modularName: 'CNL',
          // allowType: 'jpeg;jpg;png;pdf;doc;xls;xlsx;docx',
        });
        var ft = new FileTransfer();
        //注册监听上传进度
        ft.onprogress = progressEvent => {
          if (progressEvent) {
            this.percent = Math.round(
              (progressEvent.loaded * 100) / progressEvent.total
            );
          }
        };
        let params =
          "type=customerDownloadService&FixJSON={%27_method%27:%27streamSupportService.saveTempAttachment%27,%27_param%27:{pageToken:%27" +
          this.pageToken +
          "%27,fieldToken:%27" +
          this.fieldToken +
          "%27,datatype:%27Store.ecidiDoc%27}}";
        if (device.platform == "iOS") {
          // params =
          // "type=customerDownloadService&FixJSON={%27_method%27:%27streamSupportService.saveTempAttachment%27,%27_param%27:{pageToken:%27" +
          // this.pageToken + "%27,fieldToken:%27" + this.fieldToken + "%27,datatype:%27Store.ecidiDoc%27}}"
          params =
            "type=customerDownloadService&FixJSON={'_method':'streamSupportService.saveTempAttachment','_param':{'pageToken':'" +
            this.pageToken +
            "','fieldToken':'" +
            this.fieldToken +
            "',datatype:'Store.ecidiDoc'}}";
        }
        //'type=%27customerDownloadService%27&FixJSON=%7B%27_method%27:%27streamSupportService.saveTempAttachment%27,%27_param%27:%7B%27pageToken%27:%27' +
        //  this.pageToken + '%27,%27fieldToken%27:%27' + this.fieldToken + '%27%7D%7D'

        //上传地址
        let SERVER = "";
        // if (this.belongSubSys != '') {
        SERVER =
          this.COMMON_URL.replace("Action.cmd", "StreamSupportAction.cmd") +
          "?" +
          params;
        // }
        // console.log('开始上传'+SERVER)
        // if (this.server != '') {
        //   SERVER = this.server
        //   params = this.params == '' ? '' : this.params
        // }
        console.log("开始上传" + SERVER);
        if (device.platform == "iOS") {
          SERVER = encodeURI(SERVER);
        }
        console.log("optionoffline", options);
        console.log(fileURL);
        ft.upload(fileURL, SERVER, success, fail, options);
      },
      selectAll() {
        if (this.checked) {
          //实现反选
          this.checkList = [];
        } else {
          //实现全选
          this.checkList = [];
          for (var i = 0; i < this.list.length; i++) {
            this.checkList.push(this.list[i].GUID);
          }
        }
      },
      uploadRecodes() {
        this.uploadImgUrl = require("@/assets/img/upload_active.png");
        if (this.checkNetWork()) {
          this.isDisable = true;
          for (let i = this.selectedList.length - 1; i >= 0; i--) {
            console.log(this.selectedList[i]);
            this.$store.state.SQLiteDB.transaction(tx => {
              tx.executeSql(
                'SELECT * FROM PMHSE_CHECKLIST WHERE GUID = "' +
                this.selectedList[i] +
                '"',
                [],
                (tx, result) => {
                  console.log("上传测试查询结果", result);
                  if (result.rows) {
                    (function (i) {
                      $vue.uploadToServer(result.rows.item(0), i);
                    })(i);
                  } else {
                    // alert("请选择需要上传的检查单");
                    this.$vux.alert.show({
                      title: "提示",
                      content: "请选择需要上传的检查单！"
                    })
                  }
                }
              );
            });
          }
        } else {
          //执行离线状态时的任务
          console.log("离线工作！");
          // alert("请连接互联网进行上传操作！");
          this.$vux.alert.show({
            title: "提示",
            content: "请连接互联网进行上传操作！"
          })
        }
      },
      uploadToServer(data, index) {
        console.log("shiwoshiwo", data);
        this.fieldToken = data.ATTACHMENTS;
        let res = data.FILEURL;
        res = res.replace(/\|\|/g, ".");
        this.offlineUrl = res.split(",");
        var length = this.offlineUrl.length;
        if (this.imgList.length == 0) {
          var title = "日常巡检单提醒";
          var content =
            "你管理的" +
            data.PRJNAME +
            "项目有一个新的日常巡检单单。请进入【日常巡检】查看详细信息。";
          var messageto = data.SUPERVISORNAME;
          var url =
            process.env.BASE_URL +
            "qhszpm/forms/SM/SAFECHECKINSPECT/SAFECHECKINSPECT_Add.html?isBreak=false&objName=SAFECHECKINSPECT&_useType=view&_pk=GUID&_t=474914&_winid=w5240&_pkValue=" +
            data.GUID;

          var sendParams = {
            _method: "SYS_NOTICE.sendNotice",
            _param: {
              messageto: messageto,
              messagetilte: title,
              messagecontent: content,
              url: url,
              messagesenttime: new Date(),
              messageattachment: ""
            }
          };
          let sendJson = {
            FixJSON: JSON.stringify(sendParams)
          };
          this.$ajax({
              url: this.COMMON_URL,
              method: "post",
              // data: this.signMD5(sendJson)
              data: sendJson
            })
            .then(res => {})
            .catch(err => {
              console.log(err);
            });
          Vue.$vux.loading.show({
            text: "Loading"
          });
          var params = {
            _method: "formService.saveFormData",
            requestEventData: {
              eventType: "formSubmitEvent",
              formType: 1,
              bizObjId: "SAFECHECKINSPECT",
              formId: "SAFECHECKINSPECT_Add",
              buttonId: "HandleCommand_1"
            },
            flowParam: {
              defKey: "SAFECHECKINSPECT",
              nodeId: "UserTask_1",
              userCommandType: "startandsubmit",
              userCommandId: "HandleCommand_1",
              isAdmin: "false",
              taskComment: "",
              extParam: {}
            },
            _OBJ_NAME_: "SAFECHECKINSPECT",
            _FORM_ID_: "SAFECHECKINSPECT_Add",
            useType: "add",
            pageToken: this.pageToken,
            formData: {
              objName: "SAFECHECKINSPECT",
              pks: ["GUID"],
              data: [{
                rowData: [{
                    DataTarget: "GUID",
                    Value: data.GUID,
                    OriginalValue: null,
                    PK: true,
                    DataType: "String"
                  },
                  {
                    DataTarget: "STATE",
                    Value: "",
                    OriginalValue: null,
                    PK: false,
                    DataType: "String"
                  },
                  {
                    DataTarget: "ATTACHMENTS",
                    Value: "",
                    OriginalValue: null,
                    PK: false,
                    DataType: "Store.ecidiDoc"
                  },
                  {
                    DataTarget: "ATTACHMENTS2",
                    Value: "",
                    OriginalValue: null,
                    PK: false,
                    DataType: "Store.ecidiDoc"
                  },
                  {
                    DataTarget: "PRJNAME",
                    Value: data.PRJNAME,
                    OriginalValue: null,
                    PK: false,
                    DataType: "String"
                  },
                  {
                    DataTarget: "PRJNO",
                    Value: null,
                    OriginalValue: null,
                    PK: false,
                    DataType: "String"
                  },
                  {
                    DataTarget: "SYSPRJID",
                    Value: data.SYSPRJID,
                    OriginalValue: null,
                    PK: false,
                    DataType: "String"
                  },
                  {
                    DataTarget: "SUBJECT",
                    Value: data.SUBJECT,
                    OriginalValue: null,
                    PK: false,
                    DataType: "String"
                  },
                  {
                    DataTarget: "CHECKREQUIRED",
                    Value: data.CHECKREQUIRED,
                    OriginalValue: null,
                    PK: false,
                    DataType: "String"
                  },
                  {
                    DataTarget: "PLANDATE",
                    Value: data.PLANDATE + " 00:00:00.000",
                    OriginalValue: null,
                    PK: false,
                    DataType: "TimeStamp"
                  },
                  {
                    DataTarget: "FINISHDATE",
                    Value: "",
                    OriginalValue: null,
                    PK: false,
                    DataType: "TimeStamp"
                  },
                  {
                    DataTarget: "ATTACHMENTS",
                    Value: data.ATTACHMENTS,
                    OriginalValue: null,
                    PK: false,
                    DataType: "String"
                  },
                  {
                    DataTarget: "ATTACHMENTS2",
                    Value: "",
                    OriginalValue: null,
                    PK: false,
                    DataType: "String"
                  },
                  {
                    DataTarget: "DESCRIPTION",
                    Value: "",
                    OriginalValue: null,
                    PK: false,
                    DataType: "String"
                  },
                  {
                    DataTarget: "INPUTERFULLNAME",
                    Value: data.INPUTERFULLNAME,
                    OriginalValue: null,
                    PK: false,
                    DataType: "String"
                  },
                  {
                    DataTarget: "INPUTERNAME",
                    Value: data.INPUTERNAME,
                    OriginalValue: null,
                    PK: false,
                    DataType: "String"
                  },
                  {
                    DataTarget: "INPUTERDEPTNAME",
                    Value: data.INPUTERDEPTNAME,
                    OriginalValue: null,
                    PK: false,
                    DataType: "String"
                  },
                  {
                    DataTarget: "INPUTERDEPTID",
                    Value: data.INPUTERDEPTID,
                    OriginalValue: null,
                    PK: false,
                    DataType: "String"
                  },
                  {
                    DataTarget: "PHONENUM",
                    Value: data.PHONENUM,
                    OriginalValue: null,
                    PK: false,
                    DataType: "String"
                  },
                  {
                    DataTarget: "INPUTDATE",
                    Value: data.INPUTDATE,
                    OriginalValue: null,
                    PK: false,
                    DataType: "TimeStamp"
                  },
                  {
                    DataTarget: "NOTIFYCHECK",
                    Value: "",
                    OriginalValue: null,
                    PK: false,
                    DataType: "String"
                  },
                  {
                    DataTarget: "NOTIFYMETHOD",
                    Value: data.NOTIFYMETHOD,
                    OriginalValue: null,
                    PK: false,
                    DataType: "String"
                  },
                  {
                    DataTarget: "REFORMER",
                    Value: data.REFORMER,
                    OriginalValue: null,
                    PK: false,
                    DataType: "String"
                  },
                  {
                    DataTarget: "REFORMERID",
                    Value: data.REFORMERID,
                    OriginalValue: null,
                    PK: false,
                    DataType: "String"
                  },
                  {
                    DataTarget: "FLAG",
                    Value: "不合格",
                    OriginalValue: null,
                    PK: false,
                    DataType: "String"
                  },
                  {
                    DataTarget: "CHECKER",
                    Value: data.CHECKER,
                    OriginalValue: null,
                    PK: false,
                    DataType: "String"
                  },
                  {
                    DataTarget: "INSPECTMEMBERFULLNAME",
                    Value: data.INSPECTMEMBERFULLNAME,
                    OriginalValue: null,
                    PK: false,
                    DataType: "String"
                  },
                  {
                    DataTarget: "INSPECTMEMBERNAME",
                    Value: data.INSPECTMEMBERNAME,
                    OriginalValue: null,
                    PK: false,
                    DataType: "String"
                  },
                  {
                    DataTarget: "CHECKERID",
                    Value: data.CHECKERID,
                    OriginalValue: null,
                    PK: false,
                    DataType: "String"
                  },
                  {
                    DataTarget: "SUPERVISORFULLNAME",
                    Value: data.SUPERVISORFULLNAME,
                    OriginalValue: null,
                    PK: false,
                    DataType: "String"
                  },
                  {
                    DataTarget: "SUPERVISORNAME",
                    Value: data.SUPERVISORNAME,
                    OriginalValue: null,
                    PK: false,
                    DataType: "String"
                  }
                ],
                children: []
              }]
            },
            _ATTACHMENT_DELETE_IDS_: "",
            formInfo: {
              GUID: data.GUID,
              STATE: "",
              ATTACHMENTS: data.ATTACHMENTS,
              ATTACHMENTS2: "",
              PRJNAME: data.PRJNAME,
              PRJNO: "",
              SYSPRJID: data.SYSPRJID,
              SUBJECT: data.SUBJECT,
              CHECKREQUIRED: data.CHECKREQUIRED,
              PLANDATE: data.PLANDATE,
              FINISHDATE: "",
              DESCRIPTION: "",
              INPUTERFULLNAME: data.INPUTERFULLNAME,
              INPUTERNAME: data.INPUTERNAME,
              INPUTERDEPTNAME: data.INPUTERDEPTNAME,
              INPUTERDEPTID: data.INPUTERDEPTID,
              PHONENUM: data.PHONENUM,
              INPUTDATE: data.INPUTDATE,
              NOTIFYCHECK: "",
              NOTIFYMETHOD: data.NOTIFYMETHOD,
              REFORMER: data.REFORMER,
              REFORMERID: data.REFORMERID,
              FLAG: "不合格",
              CHECKER: data.CHECKER,
              INSPECTMEMBERFULLNAME: data.INSPECTMEMBERFULLNAME,
              INSPECTMEMBERNAME: data.INSPECTMEMBERNAME,
              CHECKERID: data.CHECKERID,
              SUPERVISORFULLNAME: data.SUPERVISORFULLNAME,
              SUPERVISORNAME: data.SUPERVISORNAME
            }
          };
          let json = {
            FixJSON: JSON.stringify(params)
          };
          this.$ajax({
              url: this.COMMON_URL +
                "?_objName=SAFECHECKINSPECT&_useType=add&_defKey=Flow_SAFECHECKINSPECT&_pk=GUID&_pkValue=undefined",
              method: "post",
              data: json
            })
            .then(res => {
              if (res.status == 200) {
                this.uploadImgUrl = require("@/assets/img/upload.png");
                this.$store.state.SQLiteDB.transaction(
                  tx => {
                    tx.executeSql(
                      'DELETE FROM PMHSE_CHECKLIST WHERE GUID="' + data.GUID + '"'
                    );
                  },
                  err => {
                    console.log("错误", err);
                  }
                );
              }
              this.$store.state.SQLiteDB.transaction(tx => {
                tx.executeSql(
                  "SELECT * FROM PMHSE_CHECKLIST",
                  [],
                  (tx, result) => {
                    if (result.rows.length == 0) {
                      this.list = [];
                    }
                    for (let i = 0; i < result.rows.length; i++) {
                      this.list[i] = result.rows.item(i);
                    }
                  }
                );
              });
            })
            .catch(err => {
              //console.log(err);
              alert(err);
              //this.err='';
            });
        } else {
          for (var j = 0; j < this.offlineUrl.length; j++) {
            (function (j) {
              $vue.upload($vue.offlineUrl[j], data, length, index);
            })(j);
          }
        }
        if (index == 0) {
          setTimeout(() => {
            this.isDisable = false;
          }, 3000);
        }
      },
      changeToOnline() {
        this.$router.push({
          name: "checkList",
          path: "/dailyCheck"
        });
      },
      onSwipeRight() {
        this.$router.push("/index/home");
      },
      backhome() {
        this.$router.push("/index/home");
      },
      getDataOffline() {
        console.log("!!shishi", this.proId);
        if (this.proId != undefined) {
          console.log(
            "SELECT * FROM PMHSE_CHECKLIST where SYSPRJID = '" + this.proId + "'"
          );
          this.$store.state.SQLiteDB.transaction(tx => {
            tx.executeSql(
              "SELECT * FROM PMHSE_CHECKLIST where SYSPRJID = '" +
              this.proId +
              "'",
              [],
              (tx, result) => {
                console.log(result);
                for (let i = 0; i < result.rows.length; i++) {
                  this.list[i] = result.rows.item(i);
                }

                if (this.list.length > 0) {
                  this.uploadFlag = true;
                }
              }
            );
          });
        } else {
          this.$store.state.SQLiteDB.transaction(tx => {
            tx.executeSql("SELECT * FROM PMHSE_CHECKLIST", [], (tx, result) => {
              console.log(result);
              for (let i = 0; i < result.rows.length; i++) {
                this.list[i] = result.rows.item(i);
              }
              if (this.list.length > 0) {
                this.uploadFlag = true;
              }
            });
          });
        }
      },
      openInfo(item) {
        //this.$router.push({ path: '/dailyCheck/checkInfo1', query: { GUID: item.GUID, pro: item.PRJNAME, site: item.CENTERPOSITION } })
        this.$router.push({
          path: "/dailyCheck/offlinechecklistdetial",
          query: {
            GUID: item.GUID,
            pro: item.PROJECTNAME,
            site: item.CENTERPOSITION,
            pmname: item.PRJNAME
          }
        });
      },

      dangereport() {
        //this.$router.push('/hidangereport/InspectionInfo');
        //this.$router.replace('/reportdanger')
        //console.log(this.proId)
        // this.$router.push({ path: '/dailyCheck/checkInfo', query: { centerPosition: this.site, pro: this.pro, proId: this.proId } })
        this.$router.push({
          path: "/dailyCheck/checkInfo",
          query: {
            centerPosition: this.site,
            pro: this.pro,
            proId: this.proId,
            pmname: this.proDept
          }
        });
      },

      showPro(pro) {
        return !!pro ? pro : "全部项目";
      }
    },
    // subYear(item.INPUTDATE){
    //   console.log(item.INPUTDATE);
    //   return time
    // },
    computed: {
      // userInfo () {
      //   return this.$store.state.user
      // },
      // mainPop () {
      //   return this.$store.state.mainPop
      // }
      row() {
        //页面中使用row来指代当前记录
        // console.log(this.$store.state.currentRow);
        return this.$store.state.currentRow;
      }
    },
    watch: {
      proId: function (newId, old, Id) {
        // this.reload()
        // location.reload()
        //console.log("刷新")
      },
      checkList: {
        handler: function (val, oldVal) {
          this.selectedList = this.checkList;
          if (val.length === this.list.length) {
            this.checked = true;
          } else {
            this.checked = false;
          }
        },
        deep: true
      }
    }
  };

</script>

<style scoped>
  .transition-view /deep/ .vux-header .vux-header-left .left-arrow:before {
    border-color: #cccccc;
  }

  .transition-view /deep/ .vux-header {
    background-color: #262a34 !important;
  }

  .transition-view .vux-header /deep/ .vux-header-title {
    color: #ffffff;
  }

  .card {
    background: #fff;
    margin: 10px 16px;
    padding: 20px;
    border-radius: 4px;
    overflow: hidden;
  }

  .card-title {
    font-size: 18px;
  }

  .warning {
    color: red;
    padding: 0 5px;
    background-color: pink;
    text-align: center;
    width: 140px;
    line-height: 30px;
    font-size: 14px;
  }

  .gray-label {
    color: gray;
  }

  #headeright {
    position: absolute;
    right: 15px;
    top: 10px;
    display: block;
    font-size: 14px;
    line-height: 21px;
    color: #fff;
  }

  .box-bar:before {
    content: "";
    display: block;
    height: 17px;
    position: absolute;
    border-left: 4px solid #a7aeff;
    left: 14px;
    top: 18px;
  }

  .hidanger-chosetaskfontshow {
    max-width: 70px;
    overflow-x: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    display: inline-block;
    /*设置overflow后基线位置改变，因此需要调整*/
    vertical-align: bottom;
  }

  #headeright {
    position: absolute;
    right: 0px;
    top: 5px;
    display: block;
    font-size: 14px;
    line-height: 21px;
    width: 20px;
    height: 20px;
  }

  .changeToOnline {
    margin-right: auto;
    width: 25px;
    height: 25px;
    /* margin-top: 10px; */
  }

  .selectHidanger {
    display: none;
  }

  .selectHidanger+label {
    background-color: #eeeeee;
    border-radius: 4px;
    border: 1px solid #d3d3d3;
    width: 20px;
    height: 20px;
    display: inline-block;
    text-align: center;
    vertical-align: bottom;
    line-height: 20px;
    margin: 25px;
  }

  .selectHidanger+label:hover {
    cursor: pointer;
    border: 1px solid #262a34;
  }

  .selectHidanger:checked+label {
    background-color: #eeeeee;
    background: #262a34;
  }

  .selectHidanger:checked+label:after {
    content: "\2714";
    color: white;
  }

  .upload {
    z-index: 999;
    position: absolute;
    top: 75%;
    left: 80%;
    width: 50px;
    height: 50px;
  }

  .add_form {
    position: relative;
    height: 50px;
    width: 90%;
    top: 8px;
    z-index: 999;
    left: 5%;
    background: #262a34;
    color: #ffffff;
    font-size: 16px;
    font-family: PingFang SC;
    font-weight: 400;
    line-height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .add_form_new {
    position: absolute;
    width: 50px;
    height: 50px;
    top: 80%;
    z-index: 999;
    left: 80%;
    background: #262a34;
    box-shadow: 0px 1px 13px 0px #262a34;
    border-radius: 50%;
    color: #ffffff;
    font-size: 14px;
    font-family: PingFang SC;
    font-weight: 400;
    line-height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .project_style {
    font-size: 15px;
    font-family: PingFang SC;
    font-weight: 400;
    color: rgba(25, 25, 25, 1);
    line-height: 20px;
    margin-top: 8px;
  }

  .state_time_style {
    display: flex;
    margin-top: 8px;
  }

  .fill_user {
    font-size: 13px;
    font-family: PingFang SC;
    font-weight: 400;
    color: rgba(175, 175, 175, 1);
    line-height: 20px;
  }

  .fill_time {
    /* margin-top: 8px; */
    margin-left: auto;
    font-size: 12px;
    font-family: PingFang SC;
    font-weight: 400;
    color: rgba(175, 175, 175, 1);
    line-height: 20px;
    margin-right: auto;
  }

  .sup {
    width: 100%;
    height: 10px;
    border-radius: 0;
    background-color: #f5f5f5;
  }

  /* .transition-view .vux-header .vux-header-left /deep/.left-arrow:before{
   border: 1px solid rgb(228, 15, 15);
 } */

</style>
